{% extends "catalog/base_generic.html" %}

{% block content %}
<h1>所有作者</h1>

{% if author_list %}
  <ul class="list-unstyled">
    {% for author in author_list %}
    <li class="mb-3 pb-2 border-bottom">
      <h3><a href="{% url 'author-detail' author.pk %}">{{ author.last_name }}{{ author.first_name }}</a></h3>
      <p>
        {% if author.date_of_birth %}生于: {{ author.date_of_birth|date:"Y年m月d日" }}{% endif %}
        {% if author.date_of_birth and author.date_of_death %} - {% endif %}
        {% if author.date_of_death %}卒于: {{ author.date_of_death|date:"Y年m月d日" }}{% endif %}
      </p>
    </li>
    {% endfor %}
  </ul>

  <!-- 分页 -->
  {% include "catalog/pagination.html" %}  <!-- 若有复用的分页模板 -->

{% else %}
  <p>暂无作者记录</p>
{% endif %}
{% endblock %}

{% for author in author_list %}
<div class="col-md-4 mb-4">
    <div class="card">
        <div class="card-body">
            <h5 class="card-title">{{ author.last_name }}, {{ author.first_name }}</h5>
            {% if user.is_staff %}
                <a href="{% url 'author-update' author.pk %}" class="btn btn-sm btn-warning">编辑</a>
                <a href="{% url 'author-delete' author.pk %}" class="btn btn-sm btn-danger">删除</a>
            {% endif %}
        </div>
    </div>
</div>
{% endfor %}